from selenium import webdriver
import time

from selenium.webdriver.common.by import By


class TestCase:
    def __init__(self):
        self.driver = webdriver.Chrome()

    def get_so(self):
        # 请求so页面
        self.driver.get('https://www.so.com/')
        # 定位搜索框, 写入文本信息
        self.driver.find_element(By.ID, 'input').send_keys('python自动化测试')
        #定位到搜索按钮,点击
        self.driver.find_element(By.ID, 'search-button').click()
        #获取页面标题
        print(self.driver.title)
        #判断python是否在页面标题中
        if 'python' in self.driver.title:
            print('找到了')
        else:
            print('没找到')
    def get_time(self):
        self.driver.quit()
if __name__ == '__main__':
    i = TestCase()
    i.get_so()
    time.sleep(3)
    i.get_time()



